package com.yzqp.blog.aop;

import org.springframework.stereotype.Component;

//@Aspect
@Component
public class ControllerLogAop {

//    /**
//     * 配置切入点
//     */
//    @Pointcut("execution(* com.yzqp.blog.controller.index.*.*(..))")
//    public void log() {
//    }
//
//    @Before("log()")
//    public void before(JoinPoint joinPoint) {
//        //接收到请求，记录请求内容
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = attributes.getRequest();
//        //记录下请求内容
//        LogUtil.getBean().info("URL : " + request.getRequestURL().toString());
//        LogUtil.getBean().info("HTTP_METHOD : " + request.getMethod());
//        LogUtil.getBean().info("IP : " + request.getRemoteAddr());
//        LogUtil.getBean().info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
//        LogUtil.getBean().info("ARGS : " + Arrays.toString(joinPoint.getArgs()));
//    }
//
//    @AfterReturning(returning = "ret", pointcut = "log()")
//    public void afterReturning(Object ret) {
//        LogUtil.getBean().info("RESPONSE : " + ret);
//    }

}
